﻿<UserControl x:Class="ISRecord.View.Views.OutboxView" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:p="clr-namespace:ISRecord.View.Properties"
	xmlns:converters="clr-namespace:ISRecord.View"
	xmlns:wpfExtended="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
	Loaded="ViewLoaded" Unloaded="ViewUnloaded"> 
	 
    <UserControl.InputBindings>
        <KeyBinding x:Name="exitKeyBinding" Key="ESCAPE" Command="{Binding ClearCommand}"/>
        <KeyBinding x:Name="saveKeyBinding" Key="S" Modifiers="Control" Command="{Binding SaveCommand}"/>
    </UserControl.InputBindings>
    <UserControl.Resources>
        <Style x:Key="SaveButtonStyle" TargetType="Button">
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="True">
                    <Setter Property="Content" Value="{DynamicResource SaveImage}"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Content" Value="{DynamicResource SaveDisabledImage}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="DeleteButtonStyle" TargetType="Button" >
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="True">
                    <Setter Property="Content" Value="{DynamicResource DeleteImage}"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Content" Value="{DynamicResource DeleteDisabledImage}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="FindButtonStyle" TargetType="Button">
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="True">
                    <Setter Property="Content" Value="{DynamicResource FindImage}"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Content" Value="{DynamicResource FindDisabledImage}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <ToolBar Grid.Row="0" Margin="0,0,0,10"  >
            <Button x:Name="btnAddNew" Content="{Binding Source={StaticResource AddImage}}" Margin="3"
					Command="{Binding ClearCommand}" />
            <Button  Margin="3" Command="{Binding SaveCommand}" Style="{StaticResource SaveButtonStyle}"/>
            <Button Margin="3" Command="{Binding DeleteCommand}" Style="{StaticResource DeleteButtonStyle}"/>
            <Button Margin="3" Command="{Binding FindCommand}" Style="{StaticResource FindButtonStyle}"/>

        </ToolBar>
        <Border Grid.Row="1" BorderBrush="Silver" BorderThickness="1" CornerRadius="2" Margin="3.5" Padding="5">
            <Grid  x:Name="contentGrid" PreviewKeyDown="ContenGridKeyDown" Margin="11">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Column="0" Grid.Row="0" Text="{x:Static p:Resources.OutboxNo}" VerticalAlignment="Center" />
                <TextBlock Grid.Column="0" Grid.Row="1" Text="{x:Static p:Resources.OutboxDate}" VerticalAlignment="Center" />
                <TextBlock Grid.Column="0" Grid.Row="2" Text="{x:Static p:Resources.OutboxSubject}" VerticalAlignment="Center" />
                <TextBlock Grid.Column="0" Grid.Row="3" Text="{x:Static p:Resources.OutboxGoingTo}" VerticalAlignment="Center" />
                <TextBlock Grid.Column="0" Grid.Row="4" Text="{x:Static p:Resources.OutboxAttach}" VerticalAlignment="Center" />
                <TextBlock Grid.Column="0" Grid.Row="5" Text="{x:Static p:Resources.OutboxNote}" VerticalAlignment="Center" />
                <TextBox Grid.Column="1" Grid.Row="0"  x:Name="txtOutboxNo" Width="125" 
					 HorizontalAlignment="Left" Margin="0,3,0,0" Height="30" MaxLength="8"
					 Text="{Binding Path=OutboxNo, Mode=OneWay}" PreviewKeyDown="WatchForEnterOutboxNo" 
					 IsEnabled="{Binding Path=OutboxNoEnabled}"  />
                <wpfExtended:MaskedTextBox Grid.Column="1" Grid.Row="1" Width="125" Height="30" Margin="0,3,0,0" 
									   Mask="## /##/ ####" IncludeLiterals="False" IncludePrompt="False" SelectAllOnGotFocus="True"
									   Value="{Binding Path=OutboxDate, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource dateConverter}}"
									   MaxLength="8" HorizontalAlignment="Left"/>
                <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Path=Subject, UpdateSourceTrigger=PropertyChanged}"
					 AcceptsReturn="True" TextWrapping="Wrap" Height="150" Margin="0,3,0,0" MaxLength="1000"
					 ScrollViewer.VerticalScrollBarVisibility="Auto"/>
                <TextBox Grid.Column="1" Grid.Row="3" TextWrapping="NoWrap" Text="{Binding Path=GoingTo, UpdateSourceTrigger=PropertyChanged}"
					 MinHeight="30" Margin="0,3,0,0" MaxLength="100" ScrollViewer.HorizontalScrollBarVisibility="Auto"   />
                <TextBox Grid.Column="1" Grid.Row="4" Height="30" Width="75" HorizontalAlignment="Left" Margin="0,3,0,0" MaxLength="2"
					 TextWrapping="Wrap" Text="{Binding Path=AttachmentNo, UpdateSourceTrigger=PropertyChanged}"  />
                <TextBox Grid.Column="1" Grid.Row="5" TextWrapping="Wrap" Text="{Binding Path=Notes, UpdateSourceTrigger=PropertyChanged}"
					 AcceptsReturn="True" Height="75" Margin="0,3,0,0" MaxLength="500" ScrollViewer.VerticalScrollBarVisibility="Auto" />
            </Grid>
        </Border>

    </Grid>


</UserControl>
